<template>
    <el-dialog title="编辑" :visible="isShowComDialog" @close="dialogClose" :close-on-click-modal="false">
        <el-form :model="ruleForm" :rules="rules" ref="processCompile" label-width="100px">

            <el-form-item label="名称" prop="name">
                <el-input v-model="ruleForm.name"></el-input>
            </el-form-item>
            <el-form-item  label="发布状态" property="fbzt" align="left">
                <el-switch v-model="ruleForm.fbzt"></el-switch>
            </el-form-item>
            <el-form-item label="内容" prop="nr">
                <QuillEditor class="editor" v-model="ruleForm.nr" @changeClick="quillChange1" :testa="ruleForm.nr"></QuillEditor>
            </el-form-item>

            <el-form-item label="顺序" prop="sx">
                <el-input v-model="ruleForm.sx"></el-input>
            </el-form-item>
        </el-form>

        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogClose">取 消</el-button>
            <el-button type="primary" @click="submitForm()">确 定</el-button>
        </span>

    </el-dialog>

</template>

<script>
import QuillEditor from '../../../components/pages/quillEditor.vue';
import { updateJmxz } from '@/api/systemAdministrator/auctionProcess';
export default {
    components:{
        QuillEditor
    },
    data() {
        return {
            ruleForm: {
                // id: '',
                // name: '',
                // fbzt: false,
                // sx: '',
                // nr: "",
                // bz: '',
            },
            rules: {
                name: [
                    { required: true, message: '请输入', trigger: 'blur' }
                ],
                
                sx: [
                    { required: true, message: '请输入', trigger: 'blur' }
                ],
            }
        }
    },
    props: {
        isShowComDialog: {
            type: Boolean
        },
        rowData: {
            type: Object
        }
    },
    methods: {
        dialogClose() {
            this.$emit('dialogClose');
        },
        quillChange1(data){
            this.ruleForm.nr = data;
        },
        submitForm() {
            this.$refs.processCompile.validate((valid) => {
                if (valid) {
                    if(this.ruleForm.fbzt == true){
                        this.ruleForm.fbzt = '已提交';
                    }
                    else{
                        this.ruleForm.fbzt = '未提交';
                    }
                    updateJmxz(this.ruleForm).then((res) => {
                        if(res){
                            console.log(res);
                            this.$emit('dialogClose');
                        }
                    })
                }
                else {
                    return ;
                }
            });
        },
        
    },
    mounted () {
        console.log(this.rowData);
        this.ruleForm = this.rowData;
        // if(this.rowData.fbzt == '已提交'){
        //     this.ruleForm.fbzt = true;
        // }
        // else{
        //     this.ruleForm.fbzt = false;
        // }
    }
}
</script>

<style scoped>
    .editor{
        height: 200px; 
        margin-bottom: 100px;
    }
</style>

